/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package parse;

import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;



/**
 *
 * @author phong
 */
public class Cell {

    List<CCGNode> storage;
    
    public Cell() {
        storage = new LinkedList<CCGNode>();
    }
    
    public List<CCGNode> getCCGNodes() {
        return this.storage;
    }
    
    public void add(CCGNode newnode) {
        boolean addnew = true;
        ListIterator<CCGNode> iter = this.storage.listIterator();
        while (iter.hasNext()) {
            CCGNode node = iter.next();
            if (newnode.getCat().equals(node.getCat()) && newnode.getSem().equals(node.getSem())) {
                addnew = false;
                if (newnode.getProb() > node.getProb())
                    iter.set(newnode);
                break;
            }
        }
        if (addnew) 
            storage.add(newnode);
    }
}
